﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Renci.iRods.Common;

namespace Renci.iRods.Data
{
    public class UserGroup : DataItem
    {
        [iRodsColumn(DataObjectAttributes.COL_USER_GROUP_ID)]
        public long ID { get; internal set; }

        [iRodsColumn(DataObjectAttributes.COL_USER_GROUP_NAME)]
        public string Name { get; internal set; }

        internal UserGroup(IRodsConnection connection)
            : base(connection)
        {

        }

        public UserGroup(IRodsConnection connection, string name)
            : base(connection)
        {
            this.Name = name;
        }

        public override void Refresh()
        {
            this.Exists = this.Load((q) =>
            {
                q.AddCondition(DataObjectAttributes.COL_USER_GROUP_NAME, string.Format("='{0}'", this.Name));
            });
        }

    }
}
